﻿<xsl:stylesheet version="1.0"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:srwrt="http://schemas.microsoft.com/WebParts/v3/searchresults/runtime"
                xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime"
                xmlns:msxsl="urn:schemas-microsoft-com:xslt">
  <xsl:output method="xml" indent="no"/>
  <xsl:param name="Keyword" />
  <xsl:param name="ResultsBy" />
  <xsl:param name="ViewByUrl" />
  <xsl:param name="ShowDropDown" />
  <xsl:param name="ViewByValue" />
  <xsl:param name="SortBy" />
  <xsl:param name="SortOptions" />
  <xsl:param name="Relevancy" />
  <xsl:param name="ModifiedDate" />
  <xsl:param name="DropDownOption" />
  <xsl:param name="Multiply" />
  <xsl:param name="PictureTaken" />
  <xsl:param name="IsNoKeyword" />
  <xsl:param name="IsFixedQuery" />
  <xsl:param name="ShowActionLinks" />
  <xsl:param name="MoreResultsText" />
  <xsl:param name="MoreResultsLink" />
  <xsl:param name="CollapsingStatusLink" />
  <xsl:param name="CollapseDuplicatesText" />
  <xsl:param name="AlertMeLink" />
  <xsl:param name="AlertMeText" />
  <xsl:param name="SrchRSSText" />
  <xsl:param name="SrchRSSLink" />
  <xsl:param name="SearchProviderText" />
  <xsl:param name="SearchProviderLink" />
  <xsl:param name="SearchProviderAlt"/>
  <xsl:param name="ShowMessage" />
  <xsl:param name="IsThisListScope" />
  <xsl:param name="DisplayDiscoveredDefinition" select="True" />
  <xsl:param name="NoFixedQuery" />
  <xsl:param name="NoKeyword" />
  <xsl:param name="ResultsNotFound" />
  <xsl:param name="NoResultsSuggestion" />
  <xsl:param name="NoResultsSuggestion1" />
  <xsl:param name="NoResultsSuggestion2" />
  <xsl:param name="NoResultsSuggestion3" />
  <xsl:param name="NoResultsSuggestion4" />
  <xsl:param name="NoResultsSuggestion5" />
  <xsl:param name="AdditionalResources" />
  <xsl:param name="AdditionalResources1" />
  <xsl:param name="AdditionalResources2" />
  <xsl:param name="IsSearchServer" />
  <xsl:param name="Period" />
  <xsl:param name="SearchHelp" />
  <xsl:param name="Tags" />
  <xsl:param name="Authors" />
  <xsl:param name="Date" />
  <xsl:param name="Size" />
  <xsl:param name="ViewInBrowser" />
  <xsl:param name="DefinitionIntro" />
  <xsl:param name="IdPrefix" />
  <xsl:param name="LangPickerHeading" />
  <xsl:param name="LangPickerNodeSet" />
  <xsl:param name="IsDesignMode">True</xsl:param>

  <!-- When there is keywory to issue the search -->
  <xsl:template name="dvt_1.noKeyword">
    <span class="srch-description2">
      <xsl:choose>
        <xsl:when test="$IsFixedQuery">
          <xsl:value-of select="$NoFixedQuery" />
        </xsl:when>
        <xsl:otherwise>
          <xsl:value-of select="$NoKeyword" />
        </xsl:otherwise>
      </xsl:choose>
    </span>
  </xsl:template>


  <!-- When empty result set is returned from search -->
  <xsl:template name="dvt_1.empty">
    <div class="srch-results">
      <xsl:if test="$AlertMeLink and $ShowActionLinks">
        <span class="srch-alertme" >
          <a href ="{$AlertMeLink}" id="CSR_AM1" title="{$AlertMeText}">
            <img style="vertical-align: middle;" src="/_layouts/images/bell.gif" alt="" border="0"/>
            <xsl:text disable-output-escaping="yes">&amp;nbsp;</xsl:text>
            <xsl:value-of select="$AlertMeText" />
          </a>
        </span>
      </xsl:if>

      <xsl:if test="string-length($SrchRSSLink) &gt; 0 and $ShowActionLinks">
        <xsl:if test="$AlertMeLink">
          |
        </xsl:if>
        <a type="application/rss+xml" href ="{$SrchRSSLink}" title="{$SrchRSSText}" id="SRCHRSSL">
          <img style="vertical-align: middle;" border="0" src="/_layouts/images/rss.gif" alt=""/>
          <xsl:text disable-output-escaping="yes">&amp;nbsp;</xsl:text>
          <xsl:value-of select="$SrchRSSText"/>
        </a>
        <xsl:if test="string-length($SearchProviderLink) &gt; 0">
          |
          <a href ="{$SearchProviderLink}" title="{$SearchProviderText}" >
            <img style="vertical-align: middle;" border="0" src="/_layouts/images/searchfolder.png" alt=""/>
            <xsl:text disable-output-escaping="yes">&amp;nbsp;</xsl:text>
            <xsl:value-of select="$SearchProviderText"/>
          </a>
        </xsl:if>
      </xsl:if>
    </div>

    <div class="srch-results" accesskey="W">
      <span class="srch-description2" id="CSR_NO_RESULTS">
        <p>
          <xsl:value-of select="$ResultsNotFound" />
          <xsl:text disable-output-escaping="yes">&amp;nbsp;</xsl:text>
          <strong>
            <xsl:value-of select="$Keyword" />
          </strong>
          <xsl:value-of select="$Period" />
        </p>
        <h3>
          <xsl:value-of select="$NoResultsSuggestion" />
        </h3>
        <ul>
          <li>
            <xsl:value-of select="$NoResultsSuggestion1" />
          </li>
          <li>
            <xsl:value-of select="$NoResultsSuggestion2" />
          </li>
          <li>
            <xsl:value-of select="$NoResultsSuggestion3" />
          </li>
          <xsl:if test="string-length($NoResultsSuggestion4) &gt; 0">
            <li>
              <xsl:value-of select="$NoResultsSuggestion4" />
            </li>
          </xsl:if>
          <xsl:if test="string-length($NoResultsSuggestion5) &gt; 0">
            <li>
              <xsl:value-of select="$NoResultsSuggestion5" />
            </li>
          </xsl:if>
        </ul>
        <h3>
          <xsl:value-of select="$AdditionalResources" />
        </h3>
        <ul>
          <li>
            <xsl:value-of select="$AdditionalResources1" />
            <xsl:text disable-output-escaping="yes">&amp;nbsp;</xsl:text>
            <xsl:choose>
              <xsl:when test="string-length($IsSearchServer) &gt; 0">
                <a href="javascript:HelpWindowKey('MSSEndUser_FindContent')" label="$SearchHelp">
                  <xsl:value-of select="$SearchHelp" />
                </a>
              </xsl:when>
              <xsl:otherwise>
                <a href="javascript:HelpWindowKey('WSSEndUser_FindContent')" label="$SearchHelp">
                  <xsl:value-of select="$SearchHelp" />
                </a>
              </xsl:otherwise>
            </xsl:choose>
          </li>
          <li>
            <xsl:value-of select="$AdditionalResources2" />
          </li>
        </ul>



      </span>
    </div>
  </xsl:template>

  <!-- Main body template. Sets the Results view (Relevance or date) options -->
  <xsl:template name="dvt_1.body">
    <xsl:if test="$ShowActionLinks">
      <div class="srch-sort-right2" accesskey="W">
        <xsl:if test="$LangPickerNodeSet and count($LangPickerNodeSet) &gt; 0">
          <xsl:value-of select="$LangPickerHeading"/>
          <select class="srch-dropdown" onchange="window.location.href=this.value" id="langpickerdd">
            <xsl:for-each select="$LangPickerNodeSet">
              <xsl:element name="option">
                <xsl:attribute name="value">
                  <xsl:value-of select="@url"/>
                </xsl:attribute>
                <xsl:if test="@selected = 'true'">
                  <xsl:attribute name="selected">selected</xsl:attribute>
                </xsl:if>
                <xsl:value-of select="@title"/>
              </xsl:element>
            </xsl:for-each>
          </select>
          <xsl:text disable-output-escaping="yes">&#8195;</xsl:text>
        </xsl:if>
        <xsl:if test="$ShowDropDown = 'true'">
          <xsl:value-of select="$SortBy" />
          <select id="dropdown" title="{$SortOptions}" onchange="PostToUrl(this.value)" class="srch-dropdown">
            <xsl:if test="$DropDownOption = '0' or $ViewByUrl != ''">
              <xsl:element name="option">
                <xsl:attribute name="value">
                  <xsl:value-of select="$ViewByUrl"/>
                </xsl:attribute>
                <xsl:if test="$DropDownOption = '0'">
                  <xsl:attribute
name="selected">selected</xsl:attribute>
                </xsl:if>
                <xsl:value-of select="$Relevancy"/>
              </xsl:element>
            </xsl:if>
            <xsl:if test="$DropDownOption = '1' or $ViewByUrl != ''">
              <xsl:element name="option">
                <xsl:attribute name="value">
                  <xsl:value-of select="$ViewByUrl"/>
                </xsl:attribute>
                <xsl:if test="$DropDownOption = '1'">
                  <xsl:attribute
name="selected">selected</xsl:attribute>
                </xsl:if>
                <xsl:value-of select="$ModifiedDate"/>
              </xsl:element>
            </xsl:if>
          </select>
        </xsl:if>
        <xsl:if test="$AlertMeLink">
          <xsl:if test="$ShowDropDown = 'true'">
          </xsl:if>
          <span class="srch-alertme" >
            <a href ="{$AlertMeLink}" id="CSR_AM2" title="{$AlertMeText}">
              <img style="vertical-align: middle;" src="/_layouts/images/bell.gif" alt="" border="0"/>
            </a>
            <xsl:text disable-output-escaping="yes">&#8195;</xsl:text>
          </span>
        </xsl:if>
        <xsl:if test="string-length($SrchRSSLink) &gt; 0">

          <a type="application/rss+xml" href ="{$SrchRSSLink}" title="{$SrchRSSText}" id="SRCHRSSL">
            <img style="vertical-align: middle;" border="0" src="/_layouts/images/rss.gif" alt=""/>
          </a>
          <xsl:text disable-output-escaping="yes">&#8195;</xsl:text>
        </xsl:if>
        <xsl:if test="string-length($SearchProviderLink) &gt; 0">
          <a href ="{$SearchProviderLink}" title="{$SearchProviderAlt}" >
            <img style="vertical-align: middle;" border="0" src="/_layouts/images/searchfolder.png" alt=""/>
          </a>
        </xsl:if>
      </div>
    </xsl:if>
    <div class="srch-results" accesskey="W">
      <xsl:apply-templates />
    </div>
    <xsl:call-template name="DisplayMoreResultsAnchor" />
  </xsl:template>
  <!-- This template is called for each result -->
  <xsl:template match="TotalResults">
  </xsl:template>
  <xsl:template match="NumberOfResults">
  </xsl:template>


  <xsl:template match="Result">
    <xsl:variable name="id" select="id"/>
    <xsl:variable name="currentId" select="concat($IdPrefix,$id)"/>
    <xsl:variable name="url" select="url"/>

    <xsl:variable name="otauthoralias">
      <xsl:call-template name="OTAuthorAlias"/>
    </xsl:variable>
    <!--<xsl:variable name="otauthoraliasaa" select="otauthoralias"/>-->
    <xsl:variable name="otmessagedate">
      <xsl:call-template name="OTMessageDate"/>
    </xsl:variable>
    <xsl:variable name="otmessagedateaa" select="otmessagedate"/>

    <xsl:choose>
      <xsl:when test="string-length(picturethumbnailurl) &gt; 0 and contentclass[. = 'STS_ListItem_PictureLibrary']">
        <div style=" padding-top: 2px; padding-bottom: 2px;">
          <div class="srch-picture1">
            <img src="/_layouts/images/imageresult_16x16.png" />
          </div>
          <div class="srch-picture2">
            <img class="srch-picture" src="{picturethumbnailurl}" alt="" />
          </div>
          <span>
            <ul class="srch-picturetext">
              <li class="srch-Title2 srch-Title5">
                <a href="{$url}" id="{concat('CSR_',$id)}" title="{title}">
                  <xsl:choose>
                    <xsl:when test="hithighlightedproperties/HHTitle[. != '']">
                      <xsl:call-template name="HitHighlighting">
                        <xsl:with-param name="hh" select="hithighlightedproperties/HHTitle" />
                      </xsl:call-template>
                    </xsl:when>
                    <xsl:otherwise>
                      <xsl:value-of select="title"/>
                    </xsl:otherwise>
                  </xsl:choose>
                </a>
                <!--aaa-->
                <xsl:call-template name="OTAuthorAlias">
                  <xsl:with-param name="str" select="otauthoralias" />
                </xsl:call-template>
                <!--aaa-->
              </li>

              <li>
                <xsl:if test="string-length(picturewidth) &gt; 0 and string-length(pictureheight) &gt; 0">
                  <xsl:value-of select="$Size" />
                  <xsl:value-of select="picturewidth" />
                  <xsl:value-of select="$Multiply" />
                  <xsl:value-of select="pictureheight" />

                  <xsl:if test="string-length(size) &gt; 0">
                    <xsl:if test="number(size) &gt; 0">
                      <xsl:text disable-output-escaping="yes">&#8195;</xsl:text>
                      <xsl:choose>
                        <xsl:when test="round(size div 1024) &lt; 1">
                          <xsl:value-of select="size" /> Bytes
                        </xsl:when>
                        <xsl:when test="round(size div (1024 *1024)) &lt; 1">
                          <xsl:value-of select="round(size div 1024)" />KB
                        </xsl:when>
                        <xsl:otherwise>
                          <xsl:value-of select="round(size div (1024 * 1024))"/>MB
                        </xsl:otherwise>
                      </xsl:choose>
                    </xsl:if>
                  </xsl:if>
                </xsl:if>

                <xsl:if test="string-length(datepicturetaken) &gt; 0">
                  <xsl:text disable-output-escaping="yes">&#8195;</xsl:text>
                  <xsl:value-of select="$PictureTaken" />
                  <xsl:value-of select="datepicturetaken" />
                </xsl:if>

                <xsl:if test="string-length(author) &gt; 0">
                  <xsl:text disable-output-escaping="yes">&#8195;</xsl:text>
                  <xsl:value-of select="$Authors" />
                  <xsl:value-of select="author" />
                </xsl:if>

                <xsl:if test="string-length(write) &gt; 0">
                  <xsl:text disable-output-escaping="yes">&#8195;</xsl:text>
                  <xsl:value-of select="$Date" />
                  <xsl:value-of select="write" />
                </xsl:if>

              </li>

              <li>
                <span class="srch-URL2" id="{concat($currentId,'_Url')}">
                  <xsl:choose>
                    <xsl:when test="hithighlightedproperties/HHUrl[. != '']">
                      <xsl:call-template name="HitHighlighting">
                        <xsl:with-param name="hh" select="hithighlightedproperties/HHUrl" />
                      </xsl:call-template>
                    </xsl:when>
                    <xsl:otherwise>
                      <xsl:value-of select="url"/>
                    </xsl:otherwise>
                  </xsl:choose>

                </span>
              </li>
            </ul>
          </span>
        </div>
        <div class="srch-clear">
          <img alt="" src="/_layouts/images/blank.gif" />
        </div>
      </xsl:when>
      <xsl:otherwise>
        <xsl:if test="otauthoralias[. != '']">
          <!--replace messageid-->
          <xsl:variable name ="msgid">
            <xsl:choose>
              <xsl:when test="otthreadid[.!='']">
                <xsl:value-of select="otthreadid"/>
              </xsl:when>
              <xsl:otherwise>
                <xsl:value-of select="otmessageid"/>
              </xsl:otherwise>
            </xsl:choose>
          </xsl:variable>
          <div class="tip" onmouseover="this.className='tip-onmouseover'" onmouseout="this.className='tip'">

            <table>
              <tr>
                <td style="vertical-align: top; padding-top: 6px;">
                  <div>
                    <xsl:attribute name="onclick">
                      ShowThreadPage('<xsl:value-of select="otauthoralias"/>');
                    </xsl:attribute>
                    <xsl:choose>
                      <xsl:when test="otuserimage[. > 0]">
                        <img class="srch-Picture" border="none">
                          <xsl:attribute name="src">
                            <xsl:value-of select="concat('http://officetalk/api/images/show/', otuserimage,'.jpg')"/>
                          </xsl:attribute>
                        </img>
                      </xsl:when>
                      <xsl:otherwise>
                        <img class="srch-Picture" align="absmiddle" src="/../../_layouts/images/O14_person_placeHolder_96.png" border="none" alt="{imageurl/@imageurldescription}" />
                      </xsl:otherwise>
                    </xsl:choose>

                  </div>
                </td>
                <td style="vertical-align: top; ">
                  <span class="srch-BBTitle">
                    <!-- links with the file scheme only work in ie if they are unescaped. For  
         this reason here we will render the link using disable-output-escaping if the url 
         begins with file.-->
                    <xsl:choose>
                      <xsl:when test="otoriginalpostauthoralias[. != '']">
                        <!--Title_poster replace start-->
                        <xsl:variable name="title_poster">
                          <xsl:variable name="strPoster">
                            <xsl:value-of select="concat(otauthorname,'(@',otauthoralias,')')"/>
                          </xsl:variable>
                          <xsl:choose>
                            <xsl:when test="string-length($strPoster) &gt;25">
                              <xsl:copy-of select="concat(substring($strPoster,1,25),' ...')"/>
                            </xsl:when>
                            <xsl:otherwise>
                              <xsl:copy-of select="$strPoster"/>
                            </xsl:otherwise>
                          </xsl:choose>
                        </xsl:variable>
                        <!--Title_poster replace end-->

                        <!--Title_replyer replace start-->
                        <xsl:variable name="title_replyer">
                          <xsl:variable name="strReplyer">
                            <xsl:value-of select="concat(otoriginalpostauthorname,'(@',otoriginalpostauthoralias,')')"/>
                          </xsl:variable>
                          <xsl:choose>
                            <xsl:when test="string-length($strReplyer) &gt;25">
                              <xsl:copy-of select="concat(substring($strReplyer,1,25),' ...')"/>
                            </xsl:when>
                            <xsl:otherwise>
                              <xsl:copy-of select="$strReplyer"/>
                            </xsl:otherwise>
                          </xsl:choose>
                        </xsl:variable>
                        <!--Title_replyer replace end-->

                        <a href="javascript:;">
                          <xsl:attribute name="onclick">
                            ShowThreadPage('<xsl:value-of select="otauthoralias"/>');
                          </xsl:attribute>
                          <xsl:value-of select="$title_poster"/>
                        </a>
                        replied to
                        <a href="javascript:;">
                          <xsl:attribute name="onclick">
                            ShowThreadPage('<xsl:value-of select="otoriginalpostauthoralias"/>');
                          </xsl:attribute>
                          <xsl:value-of select="$title_replyer"/>
                        </a>
                      </xsl:when>
                      <xsl:otherwise>
                        <a href="javascript:;">
                          <xsl:attribute name="onclick">
                            ShowThreadPage('<xsl:value-of select="otauthoralias"/>');
                          </xsl:attribute>
                          <xsl:value-of select="otauthorname"/>
                          (@<xsl:value-of select="otauthoralias"/>)
                        </a>
                      </xsl:otherwise>
                    </xsl:choose>
                  </span>
                  <div style="display:none;">
                    <xsl:attribute name="id">
                      <xsl:value-of select="concat('hl-',otmessageid)"/>
                    </xsl:attribute>
                    <xsl:copy-of select="hithighlightedsummary"/>
                  </div>
                  <div class="srch-BB-Description2" style="line-height: 16px;">
                    <xsl:attribute name="id">
                      <xsl:value-of select="concat('msg-',otmessageid)"/>
                    </xsl:attribute>
                    <xsl:attribute name="onclick">
                      ShowMessagePage('<xsl:value-of select="$msgid"/>');
                    </xsl:attribute>
                    <xsl:copy-of select="otmessagebody"/>
                  </div >
                  <script type="text/javascript">
                    HitHighlightedMessage("<xsl:value-of select="otmessageid"/>");
                  </script>
                  <div class="srch-BB-URL3" style="padding-top:5px;">
                    <span class="srch-BB-URL2">
                      <a class="timespan" target="_blank">
                        <xsl:attribute name="onclick">
                          ShowMessagePage('<xsl:value-of select="$msgid"/>');
                        </xsl:attribute>
                        <!--xx hours ago start-->
                        <script type="text/javascript">
                          document.write(GetTimeSpan('<xsl:value-of  select="translate(otmessagedate,'TZ',' ')"/>'));
                        </script>
                        <!--<xsl:text disable-output-escaping="yes" >
                          <![CDATA[
                                  <script type="text/javascript">                          
                                    document.write(GetTimeSpan(']]></xsl:text><xsl:value-of  select="translate(otmessagedate,'TZ',' ')"/><xsl:text disable-output-escaping="yes"><![CDATA['));</script>]]></xsl:text>-->
                        <!--{otmessagedate:<xsl:value-of select="otmessagedate"/>}-->
                        <!--xx hours ago end-->
                        via
                        <xsl:call-template name="OTMessageSource">
                          <xsl:with-param name="str" select="otmessagesource"/>
                        </xsl:call-template>
                      </a>

                      <xsl:choose>
                        <xsl:when test="otnumberofreplies[. = '1']">
                          <xsl:value-of select="concat('  | ',otnumberofreplies,' Reply')"/>
                        </xsl:when>
                        <xsl:when test="otnumberofreplies[. > '1']">
                          <xsl:value-of select="concat('  | ',otnumberofreplies,' Replies')"/>
                        </xsl:when>
                      </xsl:choose>

                    </span>
                  </div>
                </td>
              </tr>
            </table>
          </div>
        </xsl:if>
      </xsl:otherwise>

    </xsl:choose>
  </xsl:template>



  <xsl:template name="HitHighlighting">
    <xsl:param name="hh" />
    <xsl:apply-templates select="$hh"/>
  </xsl:template>

  <xsl:template match="ddd">
    &#8230;
  </xsl:template>
  <xsl:template match="c0">
    <strong>
      <xsl:value-of select="."/>
    </strong>
  </xsl:template>
  <xsl:template match="c1">
    <strong>
      <xsl:value-of select="."/>
    </strong>
  </xsl:template>
  <xsl:template match="c2">
    <strong>
      <xsl:value-of select="."/>
    </strong>
  </xsl:template>
  <xsl:template match="c3">
    <strong>
      <xsl:value-of select="."/>
    </strong>
  </xsl:template>
  <xsl:template match="c4">
    <strong>
      <xsl:value-of select="."/>
    </strong>
  </xsl:template>
  <xsl:template match="c5">
    <strong>
      <xsl:value-of select="."/>
    </strong>
  </xsl:template>
  <xsl:template match="c6">
    <strong>
      <xsl:value-of select="."/>
    </strong>
  </xsl:template>
  <xsl:template match="c7">
    <strong>
      <xsl:value-of select="."/>
    </strong>
  </xsl:template>
  <xsl:template match="c8">
    <strong>
      <xsl:value-of select="."/>
    </strong>
  </xsl:template>
  <xsl:template match="c9">
    <strong>
      <xsl:value-of select="."/>
    </strong>
  </xsl:template>

  <xsl:template name="DisplayAuthors">
    <xsl:param name="author" />
    <xsl:if test="string-length($author) &gt; 0">
      <xsl:value-of select="$Authors" />
      <xsl:choose>
        <xsl:when test="string-length(author_multival) &gt; 0">
          <xsl:for-each select="author_multival">
            <xsl:variable name="p" select="position()"/>
            <xsl:if test="$p &gt; 1">
              <xsl:text disable-output-escaping="yes">&#44;</xsl:text>
              <xsl:text disable-output-escaping="yes">&#32;</xsl:text>
            </xsl:if>
            <xsl:value-of select="."/>
          </xsl:for-each>
        </xsl:when>
        <xsl:otherwise>
          <xsl:value-of select="author"/>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:if>
  </xsl:template>

  <xsl:template name="DisplayDate">
    <xsl:param name="write" />
    <xsl:if test="string-length($write) &gt; 0">
      <xsl:if test="string-length(author) &gt; 0">
        <xsl:text disable-output-escaping="yes">&#8195;</xsl:text>
      </xsl:if>
      <xsl:value-of select="$Date" />
      <xsl:value-of select="write"/>
    </xsl:if>
  </xsl:template>


  <!-- The size attribute for each result is prepared here -->
  <xsl:template name="DisplaySize">
    <xsl:param name="size" />
    <xsl:if test="string-length($size) &gt; 0">
      <xsl:if test="number($size) &gt; 0">
        <xsl:if test="string-length(write) &gt; 0 or string-length(author) &gt; 0">
          <xsl:text disable-output-escaping="yes">&#8195;</xsl:text>
        </xsl:if>
        <xsl:value-of select="$Size" />
        <xsl:choose>
          <xsl:when test="round($size div 1024) &lt; 1">
            <xsl:value-of select="$size" /> Bytes
          </xsl:when>
          <xsl:when test="round($size div (1024 *1024)) &lt; 1">
            <xsl:value-of select="round($size div 1024)" />KB
          </xsl:when>
          <xsl:otherwise>
            <xsl:value-of select="round($size div (1024 * 1024))"/>MB
          </xsl:otherwise>
        </xsl:choose>
      </xsl:if>
    </xsl:if>
  </xsl:template>

  <xsl:template name="ViewInBrowser">
    <xsl:param name="browserlink" />
    <xsl:param name="currentId" />
    <xsl:if test="string-length($browserlink) &gt; 0">
      <span class="srch-urllink">
        <a href="{$browserlink}" id="{concat($currentId,'_VBlink')}">
          <xsl:value-of select="$ViewInBrowser" />
        </a>
      </span>
    </xsl:if>
  </xsl:template>

  <!-- A generic template to display string with non 0 string length (used for author and lastmodified time -->
  <xsl:template name="DisplayString">
    <xsl:param name="str" />
    <xsl:if test='string-length($str) &gt; 0'>
      -
      <xsl:value-of select="$str" />
    </xsl:if>
  </xsl:template>
  <!--aaaa-->
  <xsl:template name="DisplayCustomFiled">
    <xsl:param name="stra" />
    <xsl:if test='string-length($stra) &gt; 0'>
      <xsl:value-of select="$stra" />
    </xsl:if>
  </xsl:template>
  <!--aaaa-->

  <!--OTAuthorAlias-->
  <xsl:template name="OTAuthorAlias">
    <xsl:param name="str" />
    <xsl:if test='string-length($str) &gt; 0'>
      <xsl:value-of select="$str" />
    </xsl:if>
  </xsl:template>
  <!--OTAuthorAlias-->

  <!--OTDeletionDate-->
  <xsl:template name="OTDeletionDate">
    <xsl:param name="str" />
    <xsl:if test='string-length($str) &gt; 0'>
      <xsl:value-of select="$str" />
    </xsl:if>
  </xsl:template>
  <!--OTDeletionDate-->

  <!--OTMessageBody-->
  <xsl:template name="OTMessageBody">
    <xsl:param name="str" />
    <xsl:if test='string-length($str) &gt; 0'>
      <xsl:value-of select="$str" />
    </xsl:if>
  </xsl:template>
  <!--OTMessageBody-->

  <!--OTMessageDate-->
  <xsl:template name="OTMessageDate">
    <xsl:param name="str" />
    <xsl:if test='string-length($str) &gt; 0'>
      <xsl:value-of select="$str" />
    </xsl:if>
  </xsl:template>
  <!--OTMessageDate-->

  <!--OTMessageId-->
  <xsl:template name="OTMessageId">
    <xsl:param name="str" />
    <xsl:if test='string-length($str) &gt; 0'>
      <xsl:value-of select="$str" />
    </xsl:if>
  </xsl:template>
  <!--OTMessageId-->

  <!--OTMessageSource-->
  <xsl:template name="OTMessageSource">
    <xsl:param name="str" />
    <xsl:if test='string-length($str) &gt; 0'>
      <xsl:value-of select="$str" />
    </xsl:if>
  </xsl:template>
  <!--OTMessageSource-->

  <!--OTMessageUrl-->
  <xsl:template name="OTMessageUrl">
    <xsl:param name="str" />
    <xsl:if test='string-length($str) &gt; 0'>
      <xsl:value-of select="$str" />
    </xsl:if>
  </xsl:template>
  <!--OTMessageUrl-->

  <!--OTNumberOfReplies-->
  <xsl:template name="OTNumberOfReplies">
    <xsl:param name="str" />
    <xsl:if test='string-length($str) &gt; 0'>
      <xsl:value-of select="$str" />
    </xsl:if>
  </xsl:template>
  <!--OTNumberOfReplies-->

  <!--OTOriginalPostAuthorAlias-->
  <xsl:template name="OTOriginalPostAuthorAlias">
    <xsl:param name="str" />
    <xsl:if test='string-length($str) &gt; 0'>
      <xsl:value-of select="$str" />
    </xsl:if>
  </xsl:template>
  <!--OTOriginalPostAuthorAlias-->

  <!--OTOriginalPostAuthorName-->
  <xsl:template name="OTOriginalPostAuthorName">
    <xsl:param name="str" />
    <xsl:if test='string-length($str) &gt; 0'>
      <xsl:value-of select="$str" />
    </xsl:if>
  </xsl:template>
  <!--OTOriginalPostAuthorName-->

  <!--OTThreadId-->
  <xsl:template name="OTThreadId">
    <xsl:param name="str" />
    <xsl:if test='string-length($str) &gt; 0'>
      <xsl:value-of select="$str" />
    </xsl:if>
  </xsl:template>
  <!--OTThreadId-->

  <!--OTUserMySite-->
  <xsl:template name="OTUserMySite">
    <xsl:param name="str" />
    <xsl:if test='string-length($str) &gt; 0'>
      <xsl:value-of select="$str" />
    </xsl:if>
  </xsl:template>
  <!--OTUserMySite-->

  <!--OTUserPicture-->
  <xsl:template name="OTUserPicture">
    <xsl:param name="str" />
    <xsl:if test='string-length($str) &gt; 0'>
      <xsl:value-of select="$str" />
    </xsl:if>
  </xsl:template>
  <!--OTUserPicture-->
  <!--OTUserImage-->
  <xsl:template name="OTUserImage">
    <xsl:param name="str" />
    <xsl:if test='string-length($str) &gt; 0'>
      <xsl:value-of select="$str" />
    </xsl:if>
  </xsl:template>
  <!--OTUserImage-->

  <!--OTHashTag-->
  <xsl:template name="OTHashTag">
    <xsl:param name="str" />
    <xsl:if test='string-length($str) &gt; 0'>
      <xsl:value-of select="$str" />
    </xsl:if>
  </xsl:template>
  <!--OTHashTag-->

  <!--OTMention-->
  <xsl:template name="OTMention">
    <xsl:param name="str" />
    <xsl:if test='string-length($str) &gt; 0'>
      <xsl:value-of select="$str" />
    </xsl:if>
  </xsl:template>
  <!--OTMention-->

  <!-- document collapsing link setup -->
  <xsl:template name="DisplayCollapsingStatusLink">
    <xsl:param name="status"/>
    <xsl:param name="workid"/>
    <xsl:param name="id"/>
    <xsl:if test="$CollapsingStatusLink">
      <xsl:choose>
        <xsl:when test="$status=1">
          <xsl:variable name="CollapsingStatusHref" select="concat(substring-before($CollapsingStatusLink, '$$COLLAPSE_PARAM$$'), 'duplicates:&quot;', $workid, '&quot;', substring-after($CollapsingStatusLink, '$$COLLAPSE_PARAM$$'))"/>
          <span class="srch-urllink">
            <a href="{$CollapsingStatusHref}" id="$id" title="{$CollapseDuplicatesText}">
              <xsl:value-of select="$CollapseDuplicatesText"/>
            </a>
          </span>
        </xsl:when>
      </xsl:choose>
    </xsl:if>
  </xsl:template>
  <!-- The "view more results" for fixed query -->
  <xsl:template name="DisplayMoreResultsAnchor">
    <xsl:if test="$MoreResultsLink">
      <a href="{$MoreResultsLink}" id="{concat($IdPrefix,'_MRL')}">
        <xsl:value-of select="$MoreResultsText"/>
      </a>
    </xsl:if>
  </xsl:template>

  <xsl:template match="All_Results/DiscoveredDefinitions">
    <xsl:variable name="FoundIn" select="DDFoundIn" />
    <xsl:variable name="DDSearchTerm" select="DDSearchTerm" />
    <xsl:if test="$DisplayDiscoveredDefinition = 'True' and string-length($DDSearchTerm) &gt; 0">
      <script language="javascript">
        function ToggleDefinitionSelection()
        {
        var selection = document.getElementById("definitionSelection");
        if (selection.style.display == "none")
        {
        selection.style.display = "inline";
        }
        else
        {
        selection.style.display = "none";
        }
        }
      </script>
      <div class="srch-Description2 srch-definition2">
        <a href="javascript:ToggleDefinitionSelection();" id="{concat($IdPrefix,'1_DEF')}" mss_definition="true">
          <xsl:value-of select="$DefinitionIntro" />
          <strong>
            <xsl:value-of select="$DDSearchTerm"/>
          </strong>
        </a>
        <div id="definitionSelection" class="srch-Description2" style="display:none;">
          <xsl:for-each select="DDefinitions/DDefinition">
            <br/>
            <xsl:variable name="DDUrl" select="DDUrl" />
            <img style="display:inline" alt="" src="/_layouts/images/discovered_definitions_bullet.png" />
            <xsl:value-of select="DDStart"/>
            <strong>
              <xsl:value-of select="DDBold"/>
            </strong>
            <xsl:value-of select="DDEnd"/>
            <br/>
            <span class="srch-definition">
              <xsl:value-of select="$FoundIn"/>
              <xsl:text disable-output-escaping="yes">&#160;</xsl:text>
              <a href="{$DDUrl}">
                <xsl:value-of select="DDTitle"/>
              </a>
            </span>
          </xsl:for-each>
        </div>
      </div>
    </xsl:if>
  </xsl:template>

  <!-- XSL transformation starts here -->
  <xsl:template match="/">
    <xsl:if test="$AlertMeLink">
      <input type="hidden" name="P_Query" />
      <input type="hidden" name="P_LastNotificationTime" />
    </xsl:if>
    <xsl:choose>
      <xsl:when test="$IsNoKeyword = 'True'" >
        <xsl:call-template name="dvt_1.noKeyword" />
      </xsl:when>
      <xsl:when test="$ShowMessage = 'True'">
        <xsl:call-template name="dvt_1.empty" />
      </xsl:when>
      <xsl:otherwise>
<style>
html, body
{
    height:100% !important;
 
  
   overflow:hidden !important;
}
form
{
	overflow-y:scroll !important;
}

body
{
    overflow:hidden !important;/* auto; /*TODO*/
    
}
#s4-workspace
{
    
overflow-y: auto !important; width: 800px; height: 556px !important;
    }
/*===========Social Search=======================Start
add by:Chuanzhuo
add time:2012-02-08
*/
.tip
{
    border: 3px solid #FFFFFF;
    margin-bottom: 10px;
}
.tip-onmouseover
{
    border: 3px solid #DCDCDC;
    margin-bottom: 10px;
}
.srch-BB-Description2
{
    margin-top: 5px !important;
    margin-left: 8px !important;
    margin-bottom: 2px !important;
    font-family: Arial !important;
    max-width: 640px !important;
    color: #333 !important;
    font-size: 12px !important;
    cursor: pointer; /*word-break:keep-all;*/
}
.srch-Picture
{
    height: 50px;
    width: 50px;
    cursor: pointer;
}
.srch-BBTitle A:link
{
    font-family: verdana, tahoma, sans-serif !important;
    color: #000 !important;
    margin-left: 0px !important;
    font-size: 1em; /* */
    text-decoration: none !important;
}
.srch-BBTitle A:visited
{
    font-family: verdana, tahoma, sans-serif !important;
    color: #000 !important;
    margin-left: 0px !important;
    font-size: 1em;
    text-decoration: none !important;
}
.srch-BBTitle A:hover
{
    font-family: verdana, tahoma, sans-serif !important;
    color: #000 !important;
    margin-left: 0px !important;
    font-size: 1em;
    text-decoration: underline !important;
}
.srch-BBTitle
{
    padding-left: 8px !important;
    font-family: verdana, tahoma, sans-serif !important;
    color: #3f3f3f !important;
    margin-left: 0px !important;
    font-size: 1.3em !important;
}
SPAN.srch-BBTitle A:link
{
    line-height: 18px;
    font-family: "Segoe UI" !important;
    color: #d54228 !important;
    font-size: 16px !important;
}
SPAN.srch-BBTitle A:visited
{
    line-height: 18px;
    font-family: "Segoe UI" !important;
    color: #d54228 !important;
    font-size: 16px !important;
}
.srch-BB-URL3
{
    margin-left: 8px;
    overflow: hidden;
}
.srch-BB-URL3 SPAN.srch-BB-URL2
{
    font-family: Arial;
    max-width: 640px;
    color: #999 !important;
    font-size: 12px;
}
.srch-BB-URL3 SPAN.srch-BB-URL2 .timespan
{
    color: #999 !important;
    font-size: 12px;
    cursor: pointer;
}
/*===========Social Search=======================End*/
</style>
        <xsl:text disable-output-escaping="yes">

          <![CDATA[
<script>
  function GetTimeSpan(timeStart) {
    tDate = timeStart.slice(0, 10);
    tTime = timeStart.slice(11, 19);
    timeStart = tDate + " " + tTime;
    var date1 = new Date(timeStart.replace(/-/g, '/'));

    // See if the original date falls between the start and end of DST for the specified year so
    // we know how much to adjust the date by when converting it to UTC.
    isDST = isDSTDate(date1);

    // We assume that the original date is PST so we always need to adjust by at least +7 hours when converting to UTC.
    var oneHour = 1000 * 60 * 60;
    date1.setTime(date1.getTime() + oneHour * 7);

    // If the original date did not occur when DST was in effect then we need to add an additional hour when converting to UTC.
    if (!isDST) {
        date1.setTime(date1.getTime() + oneHour);
    }

    // Convert the UTC datetime to the browser's local datetime by adjusting by the TZ offset.
    var tzOffset = date1.getTimezoneOffset();
    var date2 = new Date(date1.valueOf() - tzOffset * 60 * 1000);
    return date2.toRelativeString();
}
function isDSTDate(date) {
    // The following code assumes that the supplied date is for a TZ that uses DST.
    // This is not a valid assumption for all TZ but is OK if we assume that we're
    // only concerned with dates that are relative to Pacific Standard Time (PST)
    // where DST is used.

    var myDate = new Date(date);
    var isDLS = false;
    var gmt = new Date(date); ; //new Date;
    var ssm = new Date(date); ;
    var fsn = new Date(date); ;
    var aDay = 1000 * 60 * 60 * 24;

    // Find the start date of DST for the specified year.
    // DST starts on the second Sunday in March.

    ssm.setMonth(2);
    ssm.setDate(1);
    var counter = 0;
    for (i = 0; i < 15; i++) {
        if (counter == 2) {
            break;
        }
        if (ssm.getDay() == 6) {
            counter++;
        }
        ssm.setTime(ssm.getTime() + aDay);
    }

    // Find the end date of DST for the specified year.
    // DST ends on the first Sunday in November.

    fsn.setMonth(10);
    fsn.setDate(1);

    for (i = 0; i < 7; i++) {
        if (fsn.getDay() == 6) {
            fsn.setTime(fsn.getTime() + aDay);
            break;
        }
        else {
            fsn.setTime(fsn.getTime() + aDay);
        }
    }

    // Return true if the specified date falls between the start and end of DST for the specified year.

    if (gmt < ssm || gmt >= fsn) {
        isDLS = false;
    }
    else {
        isDLS = true;
    }

    return isDLS;
}

function ShowMessagePage(otmessageid) {
    var options = {
        title: 'Conversation',
        allowMaximize: false,
        showClose: true,
        url: "../SitePages/OfficeTalkThread.aspx?messageId=" + otmessageid,
        width: 800,
        height: 600//,
        // dialogReturnValueCallback: DialogCallback
    };
    SP.UI.ModalDialog.showModalDialog(options);
    event.cancelBubble = true;
}
function ShowThreadPage(alias) {
    var options = {
        title: 'Posts',
        allowMaximize: false,
        showClose: true,
        url: "../SitePages/OfficeTalkThread.aspx?posts=" + alias,
        width: 800,
        height: 600//,
        // dialogReturnValueCallback: DialogCallback
    };
    SP.UI.ModalDialog.showModalDialog(options);
    event.cancelBubble = true;
}
function TruancateMsg(msg) {
    var maxChrs = 90;
    var ellipsis = ' ...';
    var maxlen = 0;
    var firstlen = 0;
    var secondlen = 0;
    var firstlen = msg.lastIndexOf(" ", maxChrs);
    if (firstlen < 1) {
        firstlen = msg.lastIndexOf("-", maxChrs);
        if (firstlen < 1) {
            firstlen = maxChrs;
        }
    }
    maxChrs += firstlen;
    if (msg.length > maxChrs) {
        secondlen = msg.lastIndexOf(" ", maxChrs);
        if (secondlen > firstlen) {
            maxlen = secondlen;
        }
        else {
            maxlen = maxChrs;
        }
        msg = msg.substring(0, maxlen) + ellipsis;
    }
    return msg;
}

function HitHighlightedMessage(id) {
    // var addhtml = "<div style=\"position: absolute; right: 0; bottom: 0; z-index: 10; background-color: #FFFFFF;\"> ...</div>";
    var msg = document.getElementById("msg-" + id).innerHTML;
    msg = msg.TruancateMsg(msg);
    var keys = document.getElementById("hl-" + id).innerHTML;
    pattern = /(?!(<c\d>))([^<>]+?)(?=<\/c\1)/gi;
    var keyObj = new Object();
    var keyArr = new Array();
    var kArr = keys.match(pattern);
    var keyStr = "";
    if (kArr != null) {
        for (i = 0; i < kArr.length; i++) {
            k = kArr[i].replace(/([\(\)\[\]\{\}\^\$\+\-\*\?\.\"\'\|\/\\])/gi, "\\$1");
            if (keyObj[k] == null) {
                keyArr.push("\\b" + k + "\\b");
                keyObj[k] = k;
            }
        }
        if (keyArr.length > 0) {
            keyStr = keyArr.join("|");
            repReg = new RegExp(keyStr, "gi");
            res = msg.replace(repReg, function ($0, $1, $2) {
                return "<strong>" + $0 + "</strong>";
            });
            document.getElementById("msg-" + id).innerHTML = res;
        }
    }
    else {
        document.getElementById("msg-" + id).innerHTML = msg;
    }
}

</script>
]]>
        </xsl:text>

        <xsl:call-template name="dvt_1.body"/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

  <!-- End of Stylesheet -->
</xsl:stylesheet>